package com.aiiter.web.controller.house;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.aiiter.common.annotation.Log;
import com.aiiter.common.core.controller.BaseController;
import com.aiiter.common.core.domain.AjaxResult;
import com.aiiter.common.enums.BusinessType;
import com.aiiter.house.domain.HouseBillingInformation;
import com.aiiter.house.service.IHouseBillingInformationService;
import com.aiiter.common.utils.poi.ExcelUtil;
import com.aiiter.common.core.page.TableDataInfo;

/**
 * 存储账单的基本信息，包括房产、房主、租户的关联Controller
 * 
 * @author yaocheng
 * @date 2024-08-13
 */
@RestController
@RequestMapping("/house/billingInformation")
public class HouseBillingInformationController extends BaseController
{
    @Autowired
    private IHouseBillingInformationService houseBillingInformationService;

    /**
     * 查询存储账单的基本信息，包括房产、房主、租户的关联列表
     */
    @PreAuthorize("@ss.hasPermi('house:billinginformation:list')")
    @GetMapping("/list")
    public TableDataInfo list(HouseBillingInformation houseBillingInformation)
    {
        startPage();
        List<HouseBillingInformation> list = houseBillingInformationService.selectHouseBillingInformationList(houseBillingInformation);
        return getDataTable(list);
    }

    /**
     * 导出存储账单的基本信息，包括房产、房主、租户的关联列表
     */
    @PreAuthorize("@ss.hasPermi('house:billinginformation:export')")
    @Log(title = "存储账单的基本信息，包括房产、房主、租户的关联", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, HouseBillingInformation houseBillingInformation)
    {
        List<HouseBillingInformation> list = houseBillingInformationService.selectHouseBillingInformationList(houseBillingInformation);
        ExcelUtil<HouseBillingInformation> util = new ExcelUtil<HouseBillingInformation>(HouseBillingInformation.class);
        util.exportExcel(response, list, "账单数据");
    }

    /**
     * 获取存储账单的基本信息，包括房产、房主、租户的关联详细信息
     */
    @PreAuthorize("@ss.hasPermi('house:billinginformation:query')")
    @GetMapping(value = "/{billId}")
    public AjaxResult getInfo(@PathVariable("billId") Long billId)
    {
        return success(houseBillingInformationService.selectHouseBillingInformationByBillId(billId));
    }

    /**
     * 新增存储账单的基本信息，包括房产、房主、租户的关联
     */
    @PreAuthorize("@ss.hasPermi('house:billinginformation:add')")
    @Log(title = "存储账单的基本信息，包括房产、房主、租户的关联", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody HouseBillingInformation houseBillingInformation)
    {
        return toAjax(houseBillingInformationService.insertHouseBillingInformation(houseBillingInformation));
    }

    /**
     * 修改存储账单的基本信息，包括房产、房主、租户的关联
     */
    @PreAuthorize("@ss.hasPermi('house:billinginformation:edit')")
    @Log(title = "存储账单的基本信息，包括房产、房主、租户的关联", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody HouseBillingInformation houseBillingInformation) {
        return toAjax(houseBillingInformationService.updateHouseBillingInformation(houseBillingInformation));
    }

        /**
         * 删除存储账单的基本信息，包括房产、房主、租户的关联
         */
    @PreAuthorize("@ss.hasPermi('house:billinginformation:remove')")
    @Log(title = "存储账单的基本信息，包括房产、房主、租户的关联", businessType = BusinessType.DELETE)
	@DeleteMapping("/{billIds}")
    public AjaxResult remove(@PathVariable Long[] billIds)
    {
        return toAjax(houseBillingInformationService.deleteHouseBillingInformationByBillIds(billIds));
    }
}
